package org.example.corpus.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

@Configuration
@EnableAsync
public class AsyncConfig {
    @Bean
    public Executor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(16); // 4 核心 * 4 倍
        executor.setMaxPoolSize(32); // 16 核心 * 2 倍
        executor.setQueueCapacity(100); // 较大的队列容量
        executor.setThreadNamePrefix("FileProcessingExecutor-");
        executor.initialize();
        return executor;
    }
}
